How to Configure your Unity Project to HTC Vive



Download and Install SteamVR in Steam


Before we can run Unity project in HTC Vive, we need to first setup the HTC Vive and download necessary software from Steam. This can be done by following several steps:

  • Login to your Steam account, go to ‘Library’ → ‘Tools’. Find SteamVR, right click at the status and ‘Install the Game’. See Figure 1.



external image image?w=624&h=369&rev=26&ac=1


Figure 1: Step on how to install SteamVR into your computer

  • Once installed, play the game and you will see a window pop out, where it detects your head mounting gear, your track pad, and your controller. See Figure 2.



external image image?w=271&h=154&rev=4&ac=1


Figure 2: Window that shows your setup. (The status will turn green and show ‘Ready’ when the gears are properly connected.)


Setup in Unity



In order to make your Unity project VR compatible with HTC Vive, there are two important components that need to be executed.

    • Importing SteamVR Plugin in Unity


Go to ‘Windows’ → ‘Asset Store’. Search ‘SteamVR Plugin’, download and import the package into your project. See Figure 3.


external image image?w=402&h=197&rev=10&ac=1

Figure 3: Importing SteamVR Plugin into Unity

    • New Window will pop out after importing. It will show the recommended setting for the SteamVR Plugin. Accept the recommended setting unless you have specific requirements for your project. See Figure 4.

external image image?w=302&h=320&rev=13&ac=1

Figure 4: Recommended Settings for SteamVR Plugin

    • Configuring Unity to HTC Vive


      • Find your character and add ‘SteamVR_Camera’ script by ‘Add Component’--> ‘SteamVR_Camera’. See Figure 5. Note we use Unity’s default avatar from its standard asset.After adding the SteamVR_Camera script, on the inspector, click ‘Expand’ to bring up the component of the camera.


external image image?w=342&h=177&rev=90&ac=1

Figure 5: Adding SteamVR_Camera to the character
      • To add HTC VIVE’s hand controller model, create an empty game object inside the FPSController(origin) and add another script by executing ‘Add Component’ → “SteamVR_Tracked Object”. Change the ‘Index’ in the script from ‘HMD’ to ‘None’. See Figure 6. Rename the game object to ‘Left Controller’. (Same for the right hand controller)



external image image?w=416&h=175&rev=40&ac=1

Figure 6: Adding SteamVR_Tracked Object to the character and changing the name from empty Game Object to Left Controller.

      • Add another ‘Game Object’ within your ‘Left Controller’ and add script that controls the controller by ‘Add Component’→ ‘SteamVR_Render Model’. Change the ‘Shader’ to ‘Standard Shader’.

      • In order to control the controller, in ‘FPSController (origin)’ add another script by ‘Add Component’ → ‘SteamVR_ Controller Manager’ and drag your controller to ‘Left’ and ‘Right’. See Figure 7.


external image image?w=398&h=152&rev=80&ac=1

Figure 7: Adding SteamVR_Controller Manager to the character

      • To add play area into your scene, add script in the ‘Origin’ by ‘Add Component’ → ‘SteamVR_Play Area’. A border should appear on your scene. This will configure the area that you can play with. See Figure 8.
external image image?w=405&h=255&rev=137&ac=1

Figure 8: Adding SteamVR_Play Area into your scene


    • Building the Game

      • Build the game through File → Build and Run to enjoy your first VR game.


Links:
Home
Revit to Unity